<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
</head>

<body>
    <button id="btnGET">GET</button>
    <button id="btnPOST">POST</button>
    <script>
        $(function() {
            // 1.测试get接口
            $('#btnGET').on('click', function() {
                $.ajax({
                    type: 'GET',
                    url: 'http://127.0.0.1:15/api/get',
                    data: {
                        name: 'zs',
                        age: 28
                    },
                    success: function(res) {
                        console.log(res);
                    }
                })
            })

            // POST接口
            $('#btnPOST').on('click', function() {
                    $.ajax({
                        type: 'POST',
                        url: 'http://127.0.0.1:15/api/post',
                        data: {
                            bookname: 'zs',
                            author: '施耐庵'
                        },
                        success: function(res) {
                            console.log(res);
                        }
                    })
                })
                // 4.为jsonp按钮绑定点击时间处理函数
            $().on('click', function() {
                $.ajax({
                    type: 'GET',
                    url: 'http://127.0.0.1'
                })
            })
        })
    </script>
</body>

</html>